<!--
 * @Descripttion: 系统计划任务配置
 * @version: 1.2
 * @Author: sakuya
 * @Date: 2021年7月7日09:28:32
 * @LastEditors: sakuya
 * @LastEditTime: 2021年7月10日20:56:47
-->

<template>
	<el-dialog :title="'执行一次'+form.jobDesc" v-model="visible" :width="700" destroy-on-close @closed="$emit('closed')">
		<el-form :model="form" :rules="rules" ref="dialogForm" label-width="100px" label-position="left">
			<el-form-item label="任务参数" prop="executorParam">
				<el-input v-model="form.executorParam" placeholder="请输入任务参数" clearable></el-input>
			</el-form-item>
			<el-form-item label="机器地址" prop="addressList">
				<el-input v-model="form.addressList" placeholder="请输入本次执行的机器地址，为空则从执行器获取" clearable></el-input>
			</el-form-item>

		</el-form>
		<template #footer>
			<el-button @click="visible=false">取 消</el-button>
			<el-button type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
		</template>

	</el-dialog>
</template>

<script>

export default {
	components: {
	},
	emits: ['success', 'closed'],
	data() {
		return {
			form: {
				id: "",
				jobDesc: "",
				executorParam: "",
				addressList: ""
			},
			rules: {},
			visible: false,
			isSaveing: false,
		}
	},
	watch: {},

	mounted() {

	},
	methods: {

		//显示
		open() {
			this.visible = true;
			return this;
		},
		//表单提交方法
		async submit() {
			this.$refs.dialogForm.validate(async (valid) => {
				if (valid) {
					this.isSaveing = true;
					let res = await this.$API.system.task.trigger.get(this.form);
					if (res.status != 200) {
						return;
					}
					this.visible = false;
					this.$emit('success')
					this.$message.success("计划任务执行一次成功："+ this.form.jobDesc)
				}
			})
		},
		//表单注入数据
		setData(data) {
			this.form.id = data.id
			this.form.jobDesc = data.jobDesc
			this.form.executorParam = ""
			this.form.addressList = ""
		}
	}
}
</script>

<style>
</style>
